const path = require('path')

const HtmlWebpachPlugin = require('html-webpack-plugin')

const webpack = require('webpack')

module.exports = {
	entry : ['babel-polyfill', './src/main.js'],
	output : {
		path : path.join(__dirname, 'dist'),
		filename : 'bundle.js'
	},
	plugins : [
		new HtmlWebpachPlugin({
			template : './index.html'
		}),
		new webpack.NamedModulesPlugin(),
    	new webpack.HotModuleReplacementPlugin()
	],
	devServer : {
		contentBase : './',
		hot : true
	},
	externals : {
		vue : 'Vue'
	},
	module : {
		rules : [
			{
				test : /\.css$/,
				use : ['style-loader', 'css-loader']
			},
			{
				test : /\.(jpg|png|gif|svg)$/,
				use : ['file-loader']
			},
			{
				test : /\.less$/,
				use : ['style-loader', 'css-loader', 'less-loader']
			},
			{
				test : /\.js$/,
				exclude : /(node_modules|bower_components)/,
				use : {
					loader : 'babel-loader',
					options : {
						cacheDirectory : true,
						presets : ['env'],
						plugins : ['transform-runtime']
					}
				}
			},
			{
				test : /\.vue$/,
				use : ['vue-loader']
			}
		]
	}
}